package com.jwds.digital.bios.business.api.controller.belt;

import com.jwds.digital.bios.business.core.infrastructure.dto.belt.BeltPerformanceHourReqDTO;
import com.jwds.digital.bios.business.core.infrastructure.vo.belt.BeltPerformanceHourRespVO;
import com.jwds.digital.bios.business.core.infrastructure.vo.belt.BeltPerformanceWeekRespVO;
import com.jwds.digital.bios.business.service.service.belt.IBeltPerformanceWeekService;
import com.jwds.digital.bios.business.core.infrastructure.dto.belt.BeltPerformanceWeekReqDTO;
import com.jwds.tdc.framework.application.lib.BaseResponse;
import com.jwds.tdc.framework.application.lib.page.PageRequest;
import com.jwds.tdc.framework.application.lib.page.PageResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;

/**
 * 皮带效能周表 前端控制器
 *
 * @author 林柏云
 * @date 2024-10-24
 */
@Slf4j
@Api(tags = "皮带效能周表")
@RestController
@RequestMapping("/belt/performance/week")
public class BeltPerformanceWeekController {

  @Resource
  private IBeltPerformanceWeekService service;

  @GetMapping("/{id}")
  @ApiOperation(value = "根据id查询")
  public BaseResponse<BeltPerformanceWeekRespVO> queryById(@PathVariable("id") Long id) {
    BeltPerformanceWeekRespVO respVo = service.queryById(id);
    return BaseResponse.success(respVo);
  }

  @PostMapping("/list")
  @ApiOperation(value = "分页查询")
  public BaseResponse<PageResponse<BeltPerformanceWeekRespVO>> page(@Valid @RequestBody PageRequest<BeltPerformanceWeekReqDTO> pageRequest) {
    PageResponse<BeltPerformanceWeekRespVO> respVoPage = service.page(pageRequest);
    return BaseResponse.success(respVoPage);
  }

  @PostMapping("/all")
  @ApiOperation(value = "列表查询")
  public BaseResponse<List<BeltPerformanceWeekRespVO>> list(@Valid @RequestBody BeltPerformanceWeekReqDTO reqDto) {
    List<BeltPerformanceWeekRespVO> respVoList = service.list(reqDto);
    return BaseResponse.success(respVoList);
  }

  @PostMapping("/")
  @ApiOperation(value = "新增")
  public BaseResponse<?> add(@Validated @RequestBody BeltPerformanceWeekReqDTO reqDto) {
    service.add(reqDto);
    return BaseResponse.success();
  }

  @PostMapping("/batch")
  @ApiOperation(value = "批量新增")
  public BaseResponse<?> batchAdd(@Validated @RequestBody List<BeltPerformanceWeekReqDTO> reqDtoList) {
    service.batchAdd(reqDtoList);
    return BaseResponse.success();
  }

  @PutMapping("/")
  @ApiOperation(value = "更新对象")
  public BaseResponse<?> update(@Validated @RequestBody BeltPerformanceWeekReqDTO reqDto) {
    service.update(reqDto);
    return BaseResponse.success();
  }

  @DeleteMapping("/{id}")
  @ApiOperation(value = "删除对象")
  public BaseResponse<?> delete(@PathVariable("id") Long id) {
    service.delete(id);
    return BaseResponse.success();
  }

  @DeleteMapping("/batch")
  @ApiOperation(value = "批量删除对象")
  public BaseResponse<?> batchDelete(@RequestBody List<Long> ids) {
    service.batchDelete(ids);
    return BaseResponse.success();
  }
  @PostMapping("/analyze")
  @ApiOperation(value = "周数据")
  public BaseResponse<BeltPerformanceHourRespVO> analyze(@RequestBody BeltPerformanceHourReqDTO reqDto) {
    BeltPerformanceHourRespVO beltPerformanceHourRespVO=service.analyze(reqDto);
    return BaseResponse.success(beltPerformanceHourRespVO);
  }

}
